{#**
*
* 功能描述（信息模板）
*
* @author suoya <jlusuoya@gmail.com>
* @version 1
*#}
{#include file="header.tpl" title="title" active="order"#}
<script language="javascript" type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="{#$web_root['web']#}js/region.js"></script>
{#include file="define.tpl" scope=parent#}
<div class="content middle">
    <div class="ui breadcrumb">
        <a class="section" href="index.php">主页</a>
        <i class="right"></i>
        <a class="section" href="index.php?action=order.showlist">订单管理</a>
        <i class="right"></i>
        <span class="active section">添加电话订单</span>
    </div>
    <div class="search">
        <div class="searchTitle">
            已添加商品--请先添加商品，再保存订单信息。
        </div>
        <div class="searchBar" style=" line-height: normal; padding: 5px;">
            <div class="button_bar">
                <a class="button align_right" href="{#$web_root['web']#}index.php?action=cart.index&g_sid={#$g_sid#}" target="_blank">修改购物车</a>
                <a class="button align_right" onclick="window.location.reload();
                        return false" href="#">刷新查看购物车</a>
            </div>
            <table id='orderGood' class="ui table segment">
                <thead>
                    <tr>
                        <th>商品名称</th>
                        <th>版本</th>
                        <th>规格</th>
                        <th>单位</th>
                        <th>描述</th>
                        <th>价格（￥）</th>
                        <th>折扣</th>
                        <th>数量</th>
                        <th>商品详情</th>
                    </tr>
                </thead>
                <tbody>
                    {#foreach $goods as $item#}
                        {#if $item['status'] == 0#}
                            <tr>
                                <td>{#$item['name']#}</td>
                                <td>{#$item['version']#}</td>
                                <td>{#$item['size']#}</td>
                                <td>{#$item['unit']#}</td>
                                <td>{#$item['describe']#}</td>
                                <td>{#$item['price']#}</td>
                                <td>{#$item['discount']*10#}折</td>
                                <td>{#$item['cnt']#}</td>
                                <td><a href="{#$web_root['web']#}index.php?action=food.detail&id={#$item['id']#}&version={#$item['version']#}" target="_blank">商品详情</a></td>
                            </tr>
                        {#/if#}
                    {#/foreach#}
                </tbody>
            </table>
        </div>
    </div>
    <div class="search">
        <div class="searchTitle">
            填写订单信息
        </div>
        <div class="searchBar" style=" line-height: normal; padding: 5px;">
            <form class="ui form" action="index.php?action=order.create" method="POST">
                {#if $goods|count > 0#}
                    <div class="inputDIV">
                        <label class="title">订单类型：<span class="prompt">*</span></label>
                        <select name='order_type'>{#foreach $g_ordertype as $k => $v#}<option value='{#$k#}'>{#$v#}</option>{#/foreach#}</select>
                    </div>
                    <div class="inputDIV">
                        <label class="title">订货电话：<span class="prompt">*</span></label>
                        <div class="ui input">
                            <input type="text" name='mobile_from' class="input_text" >
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title">送货方式：<span class="prompt">*</span></label>
                        <select id="delivery_type" name='delivery_type' onchange="change_dtype();">{#foreach $g_dely_type as $k => $v#}<option value='{#$k#}'>{#$v#}</option>{#/foreach#}</select>
                    </div>
                    <div class="inputDIV" id="getCake" style="display: none;">
                        <label class="title" style="vertical-align: top;">取货地址：<span class="prompt">*</span></label>
                        <div class="sub_inputDiv">
                                <label class='subTitle'>地区：</label>{#$area_come#}
                            <div class="inputDIV">
                                <label class='subTitle'>地址：</label>{#$addr_come#}
                            </div>
                        </div>
                    </div>
                    <div class="inputDIV" id="sendCake" style="display: none;">
                        <label class="title" style="vertical-align: top;">送货地址：<span class="prompt">*</span></label>
                        <div class="sub_inputDiv">
                            <input type="hidden" name="province" id="selProvinces_" value="19" />
                            <select name="city" id="selCities_" onchange="region.changed(this, 2, 'selDistricts_')">
                                <option value="0">请选择市</option>
                            </select>
                            <select name="district" id="selDistricts_" onchange="region.changed(this, 3, 'selArea_');
                                    ch_area()">
                                <option value="0">请选择区</option>
                            </select>
                            <select name="area" id="selArea_" style="display:none;" onchange="ch_area()">
                                <option value="0">请选择区域</option>
                            </select>
                            <div class="inputDIV">
                                <label class='subTitle'>地区（选择）：</label>
                                <input id='true_area' name='true_area' type='text' readonly style='width: 300px;' class="input_text" />
                            </div>
                            <div class="inputDIV">
                                <label class='subTitle'>地址：</label>
                                <input id="address" name='address' type='text'  style='width: 300px;' class="input_text" />
                            </div>
                            <div class="inputDIV">
                                <label class="subTitle">标记建筑：</label>
                                <input id="sign_building" type="text" name='sign_building' style='width: 300px;' class="input_text" >
                            </div>
                            <div class="inputDIV">
                                <label class="subTitle">邮编：</label>
                                <input id="zipcode" type="text" name='zipcode' value='100021' style='width: 100px;' class="input_text" >
                            </div>
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title">收货人：<span class="prompt">*</span></label>
                        <div class="ui input">
                            <input type="text" name='consignee' class="input_text" >
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title">收货电话：<span class="prompt">*</span></label>
                        <div class="ui input">
                            <input type="text" name='mobile_to' class="input_text" >
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title">送货日期：<span class="prompt">*</span></label>
                        <div class="ui input">
                            <input name='delivery_date' type='text' onClick="WdatePicker({minDate: '{#$cur_date#}'})" readonly="" class="input_text"/>
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title">送货时间段：<span class="prompt">*</span></label>
                        <select name='delivery_time'>{#include file="timeslot.tpl"#}</select>
                    </div>
                    <div class="inputDIV">
                        <label class="title">付款方式：<span class="prompt">*</span></label>
                        <select name='payment'>{#foreach $p_type as $k => $v#}<option value='{#$k#}'>{#$v#}</option>{#/foreach#}</select>
                    </div>
                    <div class="inputDIV">
                        <label class="title">代金券：</label>
                        <div class="ui input">
                            <input type="text" name='card_pwd' class="input_text" >
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title">积分：</label>
                        <div class="ui input">
                            <input type="text" name='integral' class="input_text" >
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title" style="vertical-align: top;">需要发票：</label>
                        <div class="sub_inputDiv">
                            <input id="need_inv" name='need_inv' type='checkbox' value="1" onclick="change_checkbox('need_inv');" />
                            <div class="inputDIV need_inv">
                                <label class='subTitle'>发票类型：</label>
                                <select id='inv_type' name='inv_type'>{#foreach $inv_type as $k => $v#}<option value='{#$k#}'>{#$v#}</option>{#/foreach#}</select>
                            </div>
                            <div class="inputDIV need_inv">
                                <label class='subTitle'>发票抬头：</label>
                                <input id='inv_title' name='inv_title' type='text' class="input_text" />
                            </div>
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title" style="vertical-align: top;">巧克力牌（免费）：</label>
                        <div class="sub_inputDiv">
                            <input id="need_card_birthday" name='need_card_birthday' type='checkbox' value="1" onclick="change_checkbox('need_card_birthday');" />
                            <div class="inputDIV need_card_birthday">
                                <label>生日祝福：</label>
                                <input type="text" name="card_birthday" class="input_text" >
                            </div>
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title">产品图册（免费）：</label>
                        <input name='need_album' type='checkbox' value="1" />
                    </div>
                    <div class="inputDIV">
                        <label class="title">生日蜡烛（免费）：</label>
                        <input name='need_candle' type='checkbox' value="1" />
                    </div>
                    <div class="inputDIV">
                        <label class="title" style="vertical-align: top;">祝福贺卡（免费）：</label>
                        <div class="sub_inputDiv">
                            <input id='need_card' name='need_card' type='checkbox' value="1" onclick="change_checkbox('need_card');" />
                            <div class="inputDIV need_card">
                                <label>祝福语：</label>
                                <input type="text" name="card_message" class="input_text" >
                            </div>
                        </div>
                    </div>
                    <div class="inputDIV">
                        <label class="title">留言：</label>
                        <textarea name="message" style="width: 400px;" rows="5"></textarea>
                    </div>
                {#/if#}
                <div class="ui error message">
                </div>
                <div class="button_bar">
                    <input type="button" value="返回" class="button align_right" onclick="gotoUrl('index.php?action=order.showlist');" />
                    {#if $goods|count > 0#}
                        <input value='提交' type='submit' class="button align_right" />
                    {#else#}
                        <a class="button align_right" href="{#$web_root['web']#}index.php?action=food.index&g_sid={#$g_sid#}" target="_blank">添加商品</a>
                    {#/if#}
                </div>
            </form>
            {#if $goods|count > 0#}
                <script>
                    $(document).ready(function() {
                        change_dtype();
                        change_checkbox('need_inv');
                        change_checkbox('need_card_birthday');
                        change_checkbox('need_card');
                        region.loadCities(19, 'selCities_');
                    });
                    
                    function change_dtype() {
                        if ($("#delivery_type").select().val() == '1') {
                            $("#getCake").hide();
                            $("#sendCake").show();
                            $("#true_area").val('');
                            $("#address").val('');
                            $("#sign_building").val('');
                            $("#zipcode").val('100021');
                        } else if ($("#delivery_type").select().val() == '2') {
                            $("#getCake").show();
                            $("#sendCake").hide();
                            $("#true_area").val('{#$area_come#}');
                            $("#address").val('{#$addr_come#}');
                        }
                    }
                    
                    function ch_area() {
                        var dist = $("#selDistricts_").val();
                        if (dist == 0)
                            return;
                        var obj = $("#selArea_");
                        var area = "";
                        if (obj.css("display") != "none") {
                            area = obj.val();
                            if (area == 0)
                                return;
                        }
                        var true_area = region.GetAddress($("#selProvinces_").val(), $("#selCities_").val(), dist, area);
                        $("#true_area").val(true_area);
                    }
                </script>
            {#/if#}
        </div>
    </div>
</div>
<script>
    $('.ui.form').form({
        mobile_from: {
            identifier: 'mobile_from',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入订货电话'
                }
            ]
        },
        address: {
            identifier: 'address',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入送货地址'
                }
            ]
        },
        consignee: {
            identifier: 'consignee',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入收货人'
                }
            ]
        },
        mobile_to: {
            identifier: 'mobile_to',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入收货电话'
                }
            ]
        },
        delivery_date: {
            identifier: 'delivery_date',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入送货日期'
                }
            ]
        },
        delivery_time: {
            identifier: 'delivery_time',
            rules: [
                {
                    type: 'empty',
                    prompt: '请选择送货时间段'
                }
            ]
        }
    });
</script>
{#include file="footer.tpl" #}
